<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>The SplPriorityQueue class</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="splminheap.compare.html">« SplMinHeap::compare</a></li>
      <li style="float: right;"><a href="splpriorityqueue.compare.html">SplPriorityQueue::compare »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="spl.datastructures.html">数据结构</a></li>
    <li>The SplPriorityQueue class</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="class.splpriorityqueue" class="reference">
 <h1 class="title">The SplPriorityQueue class</h1>
 
 
 <div class="partintro"><p class="verinfo">(PHP 5 &gt;= 5.3.0, PHP 7, PHP 8)</p>
 

  <div class="section" id="splpriorityqueue.intro">
   <h2 class="title">简介</h2>
   <p class="para">
    The SplPriorityQueue class provides the main functionalities of a 
    prioritized queue, implemented using a max heap.
   </p>
   <blockquote class="note"><p><strong class="note">注意</strong>: 
    <span class="simpara">
     The order of elements with identical priority is <em class="emphasis">undefined</em>.
     It may differ from the order in which they have been inserted.
    </span>
   </p></blockquote>
  </div>

 
  <div class="section" id="splpriorityqueue.synopsis">
   <h2 class="title">类摘要</h2>
 

   <div class="classsynopsis">
    <div class="ooclass">
     
    </div>

    <div class="classsynopsisinfo">
     <span class="ooclass">
      <span class="modifier">class</span> <strong class="classname">SplPriorityQueue</strong>
     </span>

     <span class="oointerface"><span class="modifier">implements</span> 
       <a href="class.iterator.html" class="interfacename">Iterator</a></span><span class="oointerface">,  <a href="class.countable.html" class="interfacename">Countable</a></span> {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="splpriorityqueue.compare.html" class="methodname">compare</a></span>(<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$priority1</code></span>, <span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$priority2</code></span>): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splpriorityqueue.count.html" class="methodname">count</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splpriorityqueue.current.html" class="methodname">current</a></span>(): <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splpriorityqueue.extract.html" class="methodname">extract</a></span>(): <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splpriorityqueue.getextractflags.html" class="methodname">getExtractFlags</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splpriorityqueue.insert.html" class="methodname">insert</a></span>(<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$value</code></span>, <span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$priority</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splpriorityqueue.iscorrupted.html" class="methodname">isCorrupted</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splpriorityqueue.isempty.html" class="methodname">isEmpty</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splpriorityqueue.key.html" class="methodname">key</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splpriorityqueue.next.html" class="methodname">next</a></span>(): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splpriorityqueue.recoverfromcorruption.html" class="methodname">recoverFromCorruption</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splpriorityqueue.rewind.html" class="methodname">rewind</a></span>(): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splpriorityqueue.setextractflags.html" class="methodname">setExtractFlags</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code></span>): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splpriorityqueue.top.html" class="methodname">top</a></span>(): <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="splpriorityqueue.valid.html" class="methodname">valid</a></span>(): <span class="type">bool</span></div>

   }</div>
 
  </div>
 

 
 </div>
 
 























































































 
<h2>目录</h2><ul class="chunklist chunklist_reference"><li><a href="splpriorityqueue.compare.html">SplPriorityQueue::compare</a> — Compare priorities in order to place elements correctly in the heap while sifting up</li><li><a href="splpriorityqueue.count.html">SplPriorityQueue::count</a> — Counts the number of elements in the queue</li><li><a href="splpriorityqueue.current.html">SplPriorityQueue::current</a> — Return current node pointed by the iterator</li><li><a href="splpriorityqueue.extract.html">SplPriorityQueue::extract</a> — Extracts a node from top of the heap and sift up</li><li><a href="splpriorityqueue.getextractflags.html">SplPriorityQueue::getExtractFlags</a> — Get the flags of extraction</li><li><a href="splpriorityqueue.insert.html">SplPriorityQueue::insert</a> — Inserts an element in the queue by sifting it up</li><li><a href="splpriorityqueue.iscorrupted.html">SplPriorityQueue::isCorrupted</a> — Tells if the priority queue is in a corrupted state</li><li><a href="splpriorityqueue.isempty.html">SplPriorityQueue::isEmpty</a> — Checks whether the queue is empty</li><li><a href="splpriorityqueue.key.html">SplPriorityQueue::key</a> — Return current node index</li><li><a href="splpriorityqueue.next.html">SplPriorityQueue::next</a> — Move to the next node</li><li><a href="splpriorityqueue.recoverfromcorruption.html">SplPriorityQueue::recoverFromCorruption</a> — Recover from the corrupted state and allow further actions on the queue</li><li><a href="splpriorityqueue.rewind.html">SplPriorityQueue::rewind</a> — Rewind iterator back to the start (no-op)</li><li><a href="splpriorityqueue.setextractflags.html">SplPriorityQueue::setExtractFlags</a> — Sets the mode of extraction</li><li><a href="splpriorityqueue.top.html">SplPriorityQueue::top</a> — Peeks at the node from the top of the queue</li><li><a href="splpriorityqueue.valid.html">SplPriorityQueue::valid</a> — Check whether the queue contains more nodes</li></ul>
</div>
</div></div></body></html>